﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
namespace PnJ.Aliyun.OTS.Util
{
    public class EncryptHelper
    {
        public static string ContentMd5(byte[] input)
        {

            var provider = new MD5CryptoServiceProvider();

            var computeResult = provider.ComputeHash(input);

            return Convert.ToBase64String(computeResult);
        }

        public static string HMACSHA1(string secret, string input)
        {
            HMACSHA1 hmacsha1 = new HMACSHA1();
            hmacsha1.Key = Encoding.UTF8.GetBytes(secret);
            byte[] dataBuffer = Encoding.UTF8.GetBytes(input);
            byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);
            return Convert.ToBase64String(hashBytes);
        }
    }
}
